package com.epam.cdp.jpa.backingbeans;

import java.io.Serializable;

import javax.faces.bean.ApplicationScoped;
import javax.faces.bean.ManagedBean;
import javax.faces.context.FacesContext;

import com.epam.cdp.jpa.model.User;
import com.epam.cdp.jpa.utils.SessionAttributes;

@ManagedBean
@ApplicationScoped
public class UserBackingBean implements Serializable {

    private static final long serialVersionUID = 1L;

    public String getUsername() {
        User user = (User) FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get(SessionAttributes.USER.name());
        String username = null;
        if (user != null) {
            username = user.getEmail();
        }
	return username;
    }
    
}
